import 'dart:math' as math;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book/constant/color.dart';
import 'package:flutter_book/util/extensions/string_extensions.dart';
import 'package:flutter_book/widget/debug_log/debug_util.dart';
import 'package:get/get.dart';

import 'book/page_test_book.dart';
import 'book_read/book_read_page_simulation.dart';
import 'book_read/book_read_page_slide.dart';
import 'book_read/example_screen.dart';

class TestPage extends StatelessWidget {
  const TestPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text("测试页"),
      ),
      body: _getBody(),
    );
  }


  //每一个按钮
  Widget _filterItem(String content,Function() onTap) {
    return Container(
      margin: const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
      color: AppColor.transparent,
      child: ClipRRect(
        borderRadius: BorderRadius.all(Radius.circular(14)),
        child: Material(
          borderRadius: BorderRadius.all(Radius.circular(14)),
          color: AppColor.black.withOpacity(0.08),
          child: new InkWell(
            child: Container(
              child: Text(
                content,
                style: TextStyle(fontSize: 14, color: AppColor.textPrimary2),
              ),
              padding: const EdgeInsets.only(left: 24, top: 6, right: 24, bottom: 6),
            ),
            splashColor: AppColor.textHint,
            onTap: onTap,
          ),
        ),
      ),
    );
  }

  Widget _getBody() {
    return Container(
      child: Wrap(
        alignment: WrapAlignment.start,
        children: [
          _filterItem("print打印",(){
            ("showDebugAlertTextDialog"*100).print;
          }),
          _filterItem("dialog",(){
            ("showDebugAlertTextDialog"*100).dialog;
          }),
          _filterItem("GetSnackbar",(){
            Get.snackbar("title", "message");
          }),
          _filterItem("AnimBgDemoPage",(){
            Get.snackbar("title", "message");
          }),
          _filterItem("BookTestPage",(){
            Get.to(BookTestPage());
          }),
          _filterItem("ExampleScreen",(){
            Get.to(ExampleScreen());
          }),
          _filterItem("sin30",(){
            print("pi:${math.pi}");
            print("sin:${math.sin(math.pi/(180/22.2))}");
          }),
          _filterItem("仿真翻页动画",(){
            Get.to(() => BookReadPageSimulation());
          }),
          _filterItem("滑动动画",(){
            Get.to(BookReadPageSlide());
          }),
        ],
      ),
    );
  }



}
